<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
    <style>
      .father {
        width: 300px;
        height: 300px;
        background-color: pink;
        display: flex;
        align-items: center;
        justify-content: center;
      }
      .son {
        width: 100px;
        height: 100px;
        line-height: 100px;
        text-align: center;
        background-color: skyblue;
      }
    </style>
  </head>
  <body>
    <div class="father">
      <div class="son">123</div>
    </div>
    <script>
      let father = document.querySelector(".father");
      let son = document.querySelector(".son");
      father.addEventListener("click", function () {
        console.log("父亲的冒泡被触发了");
      });
      son.addEventListener("click", function (e) {
        console.log("儿子的冒泡被触发了");
        // 阻止冒泡
        e.stopPropagation();
      });
    </script>
  </body>
</html>
